Public Class DataSourceFilter
    Inherits UIObject

    Private _DataSource As DataSource
    Public Property DataSource As DataSource
        Get
            Return _DataSource
        End Get
        Set(ByVal value As DataSource)
            _DataSource = value
            OnPropertyChanged("DataSource")
        End Set
    End Property

    Private _DataMember As DataSourceColumn
    Public Property DataMember As DataSourceColumn
        Get
            Return _DataMember
        End Get
        Set(ByVal value As DataSourceColumn)
            _DataMember = value
            OnPropertyChanged("DataMember")
        End Set
    End Property

    Private _Value As Object
    Public Property Value As Object
        Get
            Return _Value
        End Get
        Set(ByVal value As Object)
            'Dim rv = TryCast(value, DataRowView)
            Dim oldvalue = _Value
            Dim data = TryCast(value, IEnumerable)

            If data IsNot Nothing Then
                _Value = value
                Update()
                Return
            Else
                _Value = value
                Update()
                Return
            End If
            'If rv IsNot Nothing Then
            '    _Value = rv("Member")
            'Else
            If Object.Equals(_Value, value) Then Return
            Dim drv = TryCast(value, DataRowView)
            Dim odrv = TryCast(_Value, DataRowView)
            If Object.Equals(drv, odrv) Then Return
            If drv IsNot Nothing And odrv IsNot Nothing Then
                If Object.Equals(drv("Member"), odrv("Member")) Then Return
            End If

            _Value = value
            'End If
            OnPropertyChanged("Value")
            If oldvalue Is Nothing And value IsNot Nothing Then Return

        End Set
    End Property


    'Friend _owner As Windows.Controls.ListBox
    'Friend _data As DataView

    Private Sub Update()
        ModuleDashboarding._activeproject.UpdateDataSourceFilter(Me)

    End Sub
End Class
